<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/global.jsp"%>

<div id="banner-info-win" class="easyui-window" title="${banner.title }"
	style="width: 1000px; height: 500px"
	data-options="iconCls:'icon-cog',modal:true,openAnimation:'fade',closeAnimation:'slide',cache:false,collapsible:false,minimizable:false,maximizable:false">


	<form id="updateBannerButtonInputForm" method="post"
		style="display: none;" enctype="multipart/form-data">
		<input name="id" value="${banner.id}" style="display: none;" /> <input
			id="updateBannerButtonInput" type="file" name="coverFile"
			accept="image/bmp,image/png,image/gif,image.jpg,image/jpeg"
			style="display: none;">
	</form>

	<!-- 	<a id="banner-info-win-pg-save" href="javascript:;" -->
	<!-- 		onclick="banner_info_win_pg_accept()" class="easyui-linkbutton" -->
	<!-- 		data-options="iconCls:'icon-save'" style="float: right;">保存</a> -->
	<table id="banner-info-win-pg" class="easyui-propertygrid"
		style="width: 100%; height: 100%;"
		data-options="showGroup:false,scrollbarSize:0">
	</table>

	<!-- 	<div id="banner-info-status-win" class="easyui-window" title="状态设置" -->
	<!-- 		style="width: 200px; height: 200px;" -->
	<!-- 		data-options="iconCls:'icon-cog',modal:true,openAnimation:'fade',closeAnimation:'slide',cache:false,collapsible:false,minimizable:false,maximizable:false"> -->
	<!-- 		<input id="banner_info_StatusQue" style="display: none;" /> -->
	<!-- 	</div> -->

</div>

<script type="text/javascript">
	// 	function banner_info_win_pg_accept() {
	// 		try {
	// 			var id = banner_info_win_pg.propertygrid('options').data.rows[0].value;
	// 			var title = banner_info_win_pg.propertygrid('options').data.rows[1].value;
	// 			if (!title) {
	// 				$.messager.alert('提示', '标题不能为空', 'warning');
	// 				return;
	// 			}
	// 			var sort = banner_info_win_pg.propertygrid('options').data.rows[3].value;
	// 			var playtime = banner_info_win_pg.propertygrid('options').data.rows[4].value;
	// 			var summary = banner_info_win_pg.propertygrid('options').data.rows[5].value;
	// 			var info = banner_info_win_pg.propertygrid('options').data.rows[6].value;
	// 			var status = banner_info_StatusQue.combobox('getValue');
	// 			var _Data = {
	// 				id : id,
	// 				title : title,
	// 				sort : sort,
	// 				playtime : playtime,
	// 				summary : summary,
	// 				info : info,
	// 				status : status
	// 			};

	// 			$.ajax({
	// 				data : _Data,
	// 				async : false,
	// 				type : 'POST',
	// 				url : baseUrl + '/banner/update',
	// 				success : function(data) {
	// 					if (data.responseCode == '000') {
	// 						bannerListDatagrid.datagrid('endEdit',
	// 								bannerSelectIndex);

	// 						bannerListDatagrid.datagrid('acceptChanges');

	// 						bannerSelectIndex = undefined;
	// 						bannerSelectRow = undefined;
	// 						bannerEditIndex = undefined;
	// 						bannerEditRow = undefined;

	// 						$.messager.alert('提示', '修改成功', 'info');
	// 					} else {
	// 						$.messager.alert('提示', data.responseMessage, 'error');
	// 					}
	// 				}
	// 			});
	// 		} catch (e) {
	// 		}
	// 	}
</script>
<script type="text/javascript">
	var banner_info_status_win = undefined;
	var banner_info_win_pg = undefined;
	var banner_info_StatusQue = undefined;
	$(function() {
		var banner_info_win = $('#banner-info-win').window({
			onBeforeClose : function() {

			},
			onClose : function() {
				banner_info_win.panel('destroy');
			}
		});

		var pro = {
			total : 10,
			rows : []
		};
		var idRow = {
			name : 'ID',
			value : "${banner.id}",
			group : '${banner.id}'
		};
		pro.rows.push(idRow);

		var titleRow = {
			name : '标题',
			value : "${banner.title}",
			group : '${banner.id}',
			"editor" : "text"
		};
		pro.rows.push(titleRow);

		var sortRow = {
			name : '排序',
			value : "${banner.sort}",
			group : '${banner.id}',
			"editor" : "text"
		};
		pro.rows.push(sortRow);

		var statusRow = {
			name : '状态',
			value : '<div onclick="$(\'#banner-info-status-win\').window(\'open\');">${banner.statusMsg}</div>',
			group : '${banner.id}'
		};
		pro.rows.push(statusRow);

		var platformRow = {
			name : '平台',
			value : '<div onclick="$(\'#banner-info-status-win\').window(\'open\');">${banner.platformMsg}</div>',
			group : '${banner.id}'
		};
		pro.rows.push(platformRow);

		var startTimeRow = {
			name : '开始时间',
			value : '${banner.startTime}',
			group : '${banner.id}'
		};
		pro.rows.push(startTimeRow);

		var endTimeRow = {
			name : '结束时间',
			value : '${banner.endTime}',
			group : '${banner.id}'
		};
		pro.rows.push(endTimeRow);

		var urlRow = {
			name : '外链',
			value : '${banner.url}',
			group : '${banner.id}'
		};
		pro.rows.push(urlRow);

		var updateTimeRow = {
			name : '更新时间',
			value : "${banner.updateTime}",
			group : '${banner.id}'
		};
		pro.rows.push(updateTimeRow);

		var coverUrlRow = {
			name : '封面',
			value : '<img style="width: 480px; height: 300px;" id="updateBannerImg" src="${banner.coverUrl}"/>',
			group : '${banner.id}'
		};
		pro.rows.push(coverUrlRow);

		banner_info_win_pg = $('#banner-info-win-pg').propertygrid({
			'data' : pro
		});

		$('#updateBannerImg').click(function() {
			$('#updateBannerButtonInput').trigger('click');
		});

		$('#updateBannerButtonInput').change(function() {
			var _this = $(this);
			if (_this.val() && _this.val().length > 0) {
				var size = _this[0].files[0].size / 1024;
				if (size > (3 * 1024)) {
					$('#' + inputName).val("");
					$.message.alert('提示', '图片不能大于3M', 'warning');
					return;
				}
			}
			$('#updateBannerButtonInputForm').form().submit();
		});

		$('#updateBannerButtonInputForm').form({
			url : baseUrl + '/banner/updateCover',
			iframe : false,
			onSubmit : function(param) {
			},
			onProgress : function(percent) {
				$.messager.progress({
					value : percent
				});
			},
			success : function(data) {
				$.messager.progress('close');
				data = eval("(" + data + ")");

				$('#updateBannerImg').attr('src', data.data);
			}
		});

		$('.easyui-combobox').combobox();
		$('.easyui-linkbutton').linkbutton();
		// 		$('.easyui-window').window();
		// 		$('.easyui-propertygrid').propertygrid();

		banner_info_status_win = $('#banner-info-status-win').window();
		banner_info_status_win.window('close');

		banner_info_StatusQue = $('#banner_info_StatusQue')
				.combobox(
						{
							data : [ {
								"statusCode" : 1,
								"statusMsg" : "已发布",
								"selected" : "${banner.statusCode}" == "1"
							}, {
								"statusCode" : 2,
								"statusMsg" : "已下线",
								"selected" : "${banner.statusCode}" == "2"
							}, {
								"statusCode" : 3,
								"statusMsg" : "待发布",
								"selected" : "${banner.statusCode}" == "3"
							} ],
							valueField : 'statusCode',
							textField : 'statusMsg',
							onChange : function(newValue, oldValue) {
								var statusMsg = "";
								if (newValue == 1) {
									statusMsg = '已发布';
								} else if (newValue == 2) {
									statusMsg = '已下线';
								} else if (newValue == 3) {
									statusMsg = '待发布';
								}
								pro.rows[2].value = '<div onclick="$(\'#banner-info-status-win\').window(\'open\');"> '
										+ statusMsg + '   </div>';
								banner_info_win_pg
										.propertygrid('refreshRow', 2);
								banner_info_win_pg.propertygrid('options').data = pro;
							}
						});

	});
</script>

